unit payslip;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, Rptbs, RzButton, ComCtrls, StdCtrls, Buttons, ExtCtrls,
  frxClass, frxPreview, Grids, DBGrids, RzDBGrid, DB, frxExportPDF,
  frxExportXML, frxExportXLS, frxExportHTML, frxExportTXT, frxExportRTF,
  frxExportImage, frxBarcode, frxBDEComponents, frxCross, frxDMPExport,
  frxOLE, frxDCtrl, frxChart, frxRich, frxDesgn, frxGZip, frxDBSet, ADODB,
  StrUtils;

type
  Tpayslipfrm = class(TRptbsfrm)
    Label4: TLabel;
    Label5: TLabel;
    txtDoc: TEdit;
    Label6: TLabel;
    Label7: TLabel;
    txtInTax: TEdit;
    Label8: TLabel;
    Label9: TLabel;
    txtSupTax: TEdit;
    Label10: TLabel;
    CheckBox1: TCheckBox;
    txtUnprice: TEdit;
    Label11: TLabel;
    palProPrice: TPanel;
    DataSource1: TDataSource;
    RzDBGrid: TRzDBGrid;
    Label12: TLabel;
    txtMisc: TEdit;
    Label13: TLabel;
    Label14: TLabel;
    miscRemrk: TMemo;
    labTFN: TEdit;
    txtTFNType: TEdit;
    procedure palMenuResize(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure txtInTaxKeyPress(Sender: TObject; var Key: Char);
    procedure comboRFIDChange(Sender: TObject);
    procedure sptBtnClick(Sender: TObject);
    procedure CheckBox1Click(Sender: TObject);
    procedure RzBitBtn2Click(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure txtTFNTypeChange(Sender: TObject);
    procedure RzBitBtn3Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
    procedure FrmExit;override;
    procedure refreshdb;
  end;

var
  payslipfrm: Tpayslipfrm;

implementation

{$R *.dfm}

uses
  includefile, dbmodule;

procedure Tpayslipfrm.refreshdb;
begin
  with dbRpt do begin
    //sql.Clear;
    //sql.Add() 
  end;
end;

procedure Tpayslipfrm.FrmExit;
begin
  Hide;
  dbmodulefrm.T_PRODUCT.Active:=False;
  dbmodulefrm.T_PRODUCT.Close;
end;

procedure Tpayslipfrm.palMenuResize(Sender: TObject);
begin
  inherited;
  miscRemrk.Width:=palMenu.Width-miscRemrk.Left-4; 
end;

procedure Tpayslipfrm.FormCreate(Sender: TObject);
var
  I:integer;
begin
  inherited;
  for I:=0 to ComponentCount-1 do begin
    if Components[I] is TLabel then begin
      if 0<>TLabel(Components[I]).Tag then
        TLabel(Components[I]).Caption:=
                GetCaption(name,TLabel(Components[I]).Tag);
    end;
    if Components[I] is TRzBitBtn then begin
      if 0<>TRzBitBtn(Components[I]).Tag then
        TRzBitBtn(Components[I]).Caption:=
                GetCaption(name,TRzBitBtn(Components[I]).Tag);
    end;
    if Components[I] is TCheckBox then begin
      if 0<>TCheckBox(Components[I]).Tag then
        TCheckBox(Components[I]).Caption:=
                GetCaption(name,TCheckBox(Components[I]).Tag);
    end;
  end;
  frxReport.LoadFromFile(GetAppPath+'\fr3\payslip.fr3'); 
end;

procedure Tpayslipfrm.txtInTaxKeyPress(Sender: TObject; var Key: Char);
begin
  case key of
    '0'..'9',#$08,'.':begin  end;
    else begin
      key:=#00;
      Application.MessageBox(pchar(GetCaption('MsgBox',111)),
                             pchar(GetCaption('MsgBox',106)),MB_ICONINFORMATION);
    end;
  end;
end;

procedure Tpayslipfrm.comboRFIDChange(Sender: TObject);
var
  rfid:String;
  tmpPicker:TPicker;
begin
  inherited;
  if comboRFID.ItemIndex<>0 then begin
    rfid:=Trim(LeftStr(comboRFID.Text,10));
    tmpPicker:=dbmodulefrm.getPicker(rfid);
    txtDoc.Text:=tmpPicker.ID_DOC;
    labTFN.Text:=tmpPicker.TFN;
    case tmpPicker.TFNtype of
      0:txtTFNType.Text:='LOCAL';
      1:txtTFNType.Text:='FW/TFN';
      2:txtTFNType.Text:='F no TFN';
    end;
  end;
end;

procedure Tpayslipfrm.sptBtnClick(Sender: TObject);
begin
  inherited;
  comboRFIDChange(Sender);
end;

procedure Tpayslipfrm.CheckBox1Click(Sender: TObject);
begin
  inherited;
  palProPrice.Visible:=not CheckBox1.Checked;
  txtUnprice.Enabled:=CheckBox1.Checked;
  dbmodulefrm.T_PRODUCT.Active:=CheckBox1.Checked;
  if not CheckBox1.Checked then
    dbmodulefrm.T_PRODUCT.Open
  else
    dbmodulefrm.T_PRODUCT.Close;
end;

procedure Tpayslipfrm.RzBitBtn2Click(Sender: TObject);
begin
  inherited;
  frxReport.DesignReport;
end;

procedure Tpayslipfrm.FormClose(Sender: TObject; var Action: TCloseAction);
begin
  inherited;
  dbmodulefrm.T_PRODUCT.Active:=False;
  dbmodulefrm.T_PRODUCT.Close; 
end;

procedure Tpayslipfrm.txtTFNTypeChange(Sender: TObject);
begin
  inherited;
  if Trim(txtTFNType.Text)='LOCAL' then
    txtInTax.Enabled:=True
  else
    txtInTax.Enabled:=False;
end;

procedure Tpayslipfrm.RzBitBtn3Click(Sender: TObject);
begin
  inherited;
  frxReport.Print;
  refreshDB;
  frxReport.ShowReport;
end;

end.
